﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Media3D;

namespace Kinect.KinectMouseControl
{
    public class AbsoluteMouseController : IMouseController
    {
        private AutoItX3Lib.AutoItX3Class _auto;

        public void Initialize()
        {
            _auto = new AutoItX3Lib.AutoItX3Class();
        }

        private bool _lastMouseDownState;

        #region IMouseController Members

        public void SetMousePosition(System.Drawing.Point mousePosition)
        {
            _auto.MouseMove(mousePosition.X, mousePosition.Y, 0);
        }

        public void SetMouseButtonDown(bool mouseButtonDown)
        {
            // did the mouse button change state
            if (_lastMouseDownState != mouseButtonDown)
            {
                if (mouseButtonDown)
                {
                    _auto.MouseDown();
                }
                else
                {
                    _auto.MouseUp();
                }
                _lastMouseDownState = mouseButtonDown;
            }
        }

        #endregion
    }
}
